package com.ctshk.sapp.scenic.controller;


import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.enums.ScenicTicketStatus;
import com.ctshk.common.model.PageResponse;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.scenic.dto.ScenicResourceTicketDTO;
import com.ctshk.rpc.scenic.req.ScenicResourceDownBox;
import com.ctshk.rpc.scenic.req.ScenicResourceTicketReq;
import com.ctshk.rpc.scenic.service.IScenicResourceTicketService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/scenic-ticket")
@Api(value="资源中心票号管理", tags="资源中心票号管理")
public class ScenicResourceTicketController extends BaseController {

    @DubboReference
    private IScenicResourceTicketService iScenicResourceTicketService;

    @ApiOperation(value = "审批通过生成票号", notes = "审批通过生成票号")
    @PostMapping(value = "/create")
    public Result<Long> createTicket(@RequestParam(value = "productId") Long productId) {
        return iScenicResourceTicketService.createTicket(productId);
    }

    @ApiOperation(value = "票号列表查询", notes = "票号列表查询")
    @PostMapping(value = "/query-list")
    public Result<PageResponse<ScenicResourceTicketDTO>> queryList(@RequestBody ScenicResourceTicketReq scenicResourceTicketReq) {

        return Result.success(iScenicResourceTicketService.queryList(scenicResourceTicketReq));
    }

    @ApiOperation(value = "下拉选择框", notes = "下拉选择框")
    @GetMapping(value = "/down-box")
    public Result<List<ScenicResourceDownBox>> downBox(@RequestParam(value = "productId") Long productId) {

        return iScenicResourceTicketService.downBox(productId);
    }

    @ApiOperation(value = "批量售卖", notes = "批量售卖")
    @PostMapping(value = "/update-sale")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.UPDATE, operTitle = "批量售卖", operDesc = "批量售卖")
    public Result<Long> updateSale(@RequestBody List<Long> ids) {

        return iScenicResourceTicketService.updateStatus(ids, ScenicTicketStatus.BACK);
    }

    @ApiOperation(value = "批量退回", notes = "批量退回")
    @PostMapping(value = "/update-back")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.UPDATE, operTitle = "批量退回", operDesc = "批量退回")
    public Result<Long> updateBack(@RequestBody List<Long> ids) {

        return iScenicResourceTicketService.updateStatus(ids, ScenicTicketStatus.UNSOLD);
    }

   /*@ApiOperation(value = "景点门票下拉选择框", notes = "景点门票下拉选择框")
    @GetMapping(value = "/down-box")
    public Result<List<ScenicResourceDownBox>> downBox(@RequestParam(value = "productId") Long productId) {

        return iScenicResourceTicketService.downBox(productId);
    }*/
}
